#   Copyright (C) 2008      Tri Tech Information Systems Inc.
# 
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
# 
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
# 
#   You should have received a copy of the GNU General Public License along
#   with this program; if not, write to the Free Software Foundation, Inc.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#   
from pyxx.callable import MethodWrapper, BaseFunctionWrapper
from pyxx.virtual import VirtualMethodWrapper
from pyxx.constructor import ConstructorWrapper, InterfaceConstructorWrapper

def PickMethodWrapper(meth, klass, is_interface):    
    """
    This function picks an actual MethodWrapper class to use
    """
    if meth.name == klass.name:
        # if we have a constructor, we no longer assume
        # we are going to have a default one
        if is_interface:
            return InterfaceConstructorWrapper(meth, klass)
        else:
            return ConstructorWrapper(meth, klass)
    else:
        if is_interface and meth.isVirtual:
            return VirtualMethodWrapper( MethodWrapper(meth, klass), klass)
        else:            
            return MethodWrapper(meth, klass)

